feat: implement structured error handling#50
Merged
besart-finsweet merged 3 commits intomasterfrom Apr 22, 2026
Merged
Conversation
…nd related utilities
There was a problem hiding this comment.
Pull request overview
This PR introduces a structured, SDK-like error model across the Firestore REST client so consumers can reliably branch on stable error codes instead of parsing error messages.
Changes:
- Add
FirestoreError/FirestoreErrorCode, plus helpers (throw_if_error,safe_fetch) to normalize REST + network failures. - Update core operations (get/create/set/update/query/batch/remove) to use the new structured error handling.
- Document the new error contract and add unit tests around the new behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/error.ts | Adds FirestoreError, status-to-code mapping, and helpers for consistent error throwing/wrapping. |
| src/error.test.ts | Adds tests asserting errors surface as FirestoreError with stable codes. |
| src/get.ts | Switches to safe_fetch + throw_if_error for structured errors. |
| src/create.ts | Switches to safe_fetch + throw_if_error for structured errors. |
| src/set.ts | Switches to safe_fetch + throw_if_error for structured errors. |
| src/update.ts | Switches to safe_fetch + throw_if_error for structured errors. |
| src/query.ts | Switches to safe_fetch + throw_if_error, with explicit union typing for error responses. |
| src/batch.ts | Switches to safe_fetch + throw_if_error, returning typed commit response on success. |
| src/remove.ts | Uses safe_fetch and attempts to throw structured errors on non-OK responses. |
| src/index.ts | Re-exports FirestoreError / FirestoreErrorCode as part of the public API. |
| README.md | Documents the new error handling model and enumerates error codes/fields. |
| .changeset/structured-firestore-errors.md | Declares a minor release and describes the new error behavior/fields. |
| .vscode/settings.json | Adds “Firestore” to cSpell dictionary. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
alexiglesias93
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.